package com.cff.action;

import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;

import com.cff.AwtPos;
import com.cff.common.Constant;
import com.cff.common.SimpleFrame;
import com.cff.util.EventUtil;
import com.cff.util.FileUtil;
import com.cff.util.SignTools;

public class ProjectAcctActionListener implements ActionListener {
	SimpleFrame frame;
	Panel controlPanel;
	JButton connectButton;   
    JButton acctButton;  
    JButton allButton;
    TextArea message;
    TextArea resultText;
    JLabel portLabel;
    JTextField portText;
    JTextField macText;
    Label headerLabel;
    JLabel macLabel;
    private static Properties confPro = null;
	public ProjectAcctActionListener() {
		super();
	}

	public ProjectAcctActionListener(SimpleFrame frame,Panel controlPanel, JButton connectButton, JButton acctButton, JButton allButton,
			TextArea message, TextArea resultText, JLabel portLabel, JTextField portText, JTextField macText,
			Label headerLabel, JLabel macLabel) {
		super();
		this.frame = frame;
		this.controlPanel = controlPanel;
		this.connectButton = connectButton;
		this.acctButton = acctButton;
		this.allButton = allButton;
		this.message = message;
		this.resultText = resultText;
		this.portLabel = portLabel;
		this.portText = portText;
		this.macText = macText;
		this.headerLabel = headerLabel;
		this.macLabel = macLabel;
	}


	@Override
	public void actionPerformed(ActionEvent e) {
		confPro = FileUtil.getInstance();
		frame.setBounds(100, 100, AwtPos.ACCTWEITH, AwtPos.ACCTHEIGH);
		controlPanel.removeAll();
		controlPanel.removeNotify();
		controlPanel.addNotify();
		controlPanel.add(connectButton);
        controlPanel.add(acctButton);
        controlPanel.add(allButton);
        connectButton.setBounds(160,270,80,30);
        acctButton.setBounds(280,270,80,30);
        allButton.setBounds(400,270,80,30);
        message.setBounds(50, 60, controlPanel.getWidth()-100, 80);
        headerLabel.setBounds(50, 150, 50, 50);
        headerLabel.setText("result:");
        resultText.setBounds(120, 180, controlPanel.getWidth()-200, 80);
        controlPanel.add(message);
        controlPanel.add(headerLabel);
        controlPanel.add(resultText);
        portLabel.setBounds(10, 1, 220, 50);
        portLabel.setText("端口号：");
        portText.setBounds(235, 8, 80, 30);
        portText.setText(confPro.getProperty("portText"));
        macLabel.setBounds(360, 1, 80, 50);
        macLabel.setText("mac密钥：");
        macText.setBounds(450, 8, 150, 30);
        macText.setText(confPro.getProperty("macText"));
        controlPanel.add(portLabel);
        controlPanel.add(portText);
        controlPanel.add(macLabel);
        controlPanel.add(macText);
	}

}
